<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: red;

        }

        .nav {
            color: wheat;
            text-align: center;
        }

        .box {
            width: 400px;
            height: 400px;
            background-color: green;
            border: 5px solid rebeccapurple;
            padding: 10px;
            margin: 100px auto;
        }
    </style>
</head>

<body>
    <div class="nav">123</div>
    <script>
        // 找到元素
        const div = document.querySelector('div')
        // 添加类名 class是关键字，统一用className
        div.className = 'box'
    </script>
</body>

</html>